package com.voice.call.controller;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.voice.call.common.Const;
import com.voice.call.common.Result;
import com.voice.call.common.ResultEnum;
import com.voice.call.service.VideoLibraryService;
import com.voice.call.utils.JSONUtil;
import com.voice.call.version.ApiVersion;


//常用接口 
@RestController
@RequestMapping("/api/{version}/common/")
public class CommonController {
	
	private final Logger log = LoggerFactory.getLogger(CommonController.class);
	
	@Resource
	private VideoLibraryService videoLibraryService;
	
	@ResponseBody
	@ApiVersion(1)
	@RequestMapping(value = "video/list", method = RequestMethod.POST, produces = Const.JSON_UTF8)
	public Result videoList(HttpServletRequest request,@RequestBody Map<String, Object> params){
		
		//log.debug("参数:{}",JSONUtil.objectToJson(params));
		// 判断入参
		if (null == params ||  params.get("page") == null || params.get("pagesize") == null) {
			//log.error(ResultEnum.PARAM_ERROR.getMsg());
			return new Result(ResultEnum.PARAM_ERROR);
		}
		
		
		Integer page =Integer.valueOf(params.get("page").toString());
		Integer pagesize = Integer.valueOf(params.get("pagesize").toString());
		
		return videoLibraryService.getVideoList(page, pagesize);
	}

}
